<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 思路：设置一个arr1数组，把不等于0的值移入arr1数组中
    let arr = [1, 34, 0, 0, 5, 0, 7, 0, 18, 16, 0, 33, 0]
    let arr1 = []
    for (let i = 0; i < arr.length; i++) {
      if (arr[i] !== 0) {
        arr1.push(arr[i])
      }
    }
    console.log(arr1);
  </script>
</body>

</html>